<?php

namespace app\weixin\controller;


use think\Db;
use think\Request;
use app\user\model\Service_supply;
use app\user\model\Service_purchase;
class Service extends \think\Controller
{
    public function purchases()
    {


        $list = Db::table('Service_supply')->join('unit', 'Service_supply.unit=unit.unid')->limit(50)->order('ID desc')->select();
        $this->assign('list', $list);
        return view();


    }

    public function purchase()
    {

       $t=Db::table('service_purchase')->join('unit', 'service_purchase.unit=unit.unid')->where('ID',input('id'))->find();

        $list = Db::table('service_purchase')->join('unit', 'service_purchase.unit=unit.unid')->limit(6)->order('rand()')->select();
        $this->assign('list', $list);
       $this->assign('t',$t);
        return view();
    }



    public function logisticss(){

        $where['State']=3;
        $list = Db::table('service_logistics')->where($where)->limit(50)->order('ID desc')->select();
        $this->assign('list', $list);
        return view();





    }


    public function logistics(){

        $t=Db::table('service_logistics')->where('ID',input('id'))->find();
        $this->assign('t',$t);
        $where['LogisticsID']=input('id');
        $list = Db::table('service_logistics_car')->where($where)->limit(50)->order('ID desc')->select();
        $this->assign('list', $list);
        return view();
    }


    public function services(){

        $act=input('cateid','精选常备');
        $where['Industry']=$act;

        $where['State']=3;

        $list = Db::table('service_company')->where($where)->limit(150)->order('ID desc')->select();
        $this->assign('list', $list);



        $this->assign('act',$act);
        $catelist=Db::table('service_cate')->where(['type'=>'company'])->select();
        $this->assign('catelist',$catelist);

        return view();
    }


    public function service(){

        $t=Db::table('service_company')->where('ID',input('id'))->find();
        $this->assign('t',$t);

        return view();
    }


    public function customs(){



        $list = Db::table('service_custom')->where($where)->limit(50)->order('ID desc')->select();
        $this->assign('list', $list);
        return view();

        return view();
    }


    public function custom(){

        $t=Db::table('service_custom')->where('ID',input('id'))->find();
        $this->assign('t',$t);

        return view();
    }


    public function supplys(Service_purchase $Service_purchase){

        $list = $Service_purchase->select();
        //dump($list);die;
        $this->assign('list', $list);
        return view();


    }

    public  function supply(){
        $where['State']=3;
        $list = Db::table('service_supply')->join('unit', 'service_supply.Unit=unit.unid')->limit(5)->order('rand()')->select();
        $t=Db::table('service_supply')->where('ID',input('id'))->find();
        $this->assign('t',$t);
        $this->assign('list',$list);


        return view();



    }


    public function leases(){


        $list = Db::table('service_Lease')->where($where)->limit(50)->order('ID desc')->select();
        $this->assign('list', $list);


        return view();


    }

    public  function lease(){
        $where['State']=3;
        $list = Db::table('service_Lease')->where($where)->limit(5)->order('rand()')->select();
        $t=Db::table('service_Lease')->where('ID',input('id'))->find();
        $this->assign('t',$t);
        $this->assign('list',$list);


        return view();



    }


}
